package com.learn.spring_jdbc;

import com.learn.spring_jdbc.dao.AccountDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

@ComponentScan
@PropertySource("classpath:application.properties")
public class SpringJdbc {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringJdbc.class);
        AccountDao accountDao = applicationContext.getBean("accountDao", AccountDao.class);
        
        // 增
        accountDao.addAccount("王五", 2000);
        
        // 删
        accountDao.deleteAccount(4);
        
        // 改
        accountDao.updateAccount(3, "??", 0);
        
        // 查
        System.out.println(accountDao.getAllAccounts().toString());
        System.out.println(accountDao.getAccountById(1).toString());
    }
}
